package com.fbs.wowo.manage.mapper;

import com.fbs.wowo.manage.entity.AccountDetail;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface AccountDetailMapper {
    @Delete({
        "delete from account_detail",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @InsertProvider(type=AccountDetailSqlProvider.class, method="insertSelective")
    int insertSelective(AccountDetail record);

    @Select({
        "select",
        "id, user_id, bank_num, tel, bank_code,wx_open_id, name, id_num, cert_type, front_img, contrary_img, ",
        "hand_img, create_time, company_name, company_cert_type, company_cert_num, company_bl_img, ",
        "company_attorney_img, type, cert_status",
        "from account_detail",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
        @Result(column="bank_num", property="bankNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
        @Result(column="bank_code", property="bankCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="wx_open_id", property="wxOpenId", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="id_num", property="idNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="cert_type", property="certType", jdbcType=JdbcType.TINYINT),
        @Result(column="front_img", property="frontImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="contrary_img", property="contraryImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="hand_img", property="handImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR),
        @Result(column="company_cert_type", property="companyCertType", jdbcType=JdbcType.TINYINT),
        @Result(column="company_cert_num", property="companyCertNum", jdbcType=JdbcType.VARCHAR),
        @Result(column="company_bl_img", property="companyBlImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="company_attorney_img", property="companyAttorneyImg", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="cert_status", property="certStatus", jdbcType=JdbcType.TINYINT)
    })
    AccountDetail selectByPrimaryKey(String id);

    @UpdateProvider(type=AccountDetailSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(AccountDetail record);

    @Select({
            "select",
            "id, user_id, bank_num, tel, bank_code,wx_open_id, name, id_num, cert_type, front_img, contrary_img, ",
            "hand_img, create_time, company_name, company_cert_type, company_cert_num, company_bl_img, ",
            "company_attorney_img, type, cert_status",
            "from account_detail",
            "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
            @Result(column="bank_num", property="bankNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
            @Result(column="bank_code", property="bankCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="wx_open_id", property="wxOpenId", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="id_num", property="idNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="cert_type", property="certType", jdbcType=JdbcType.TINYINT),
            @Result(column="front_img", property="frontImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="contrary_img", property="contraryImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="hand_img", property="handImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_cert_type", property="companyCertType", jdbcType=JdbcType.TINYINT),
            @Result(column="company_cert_num", property="companyCertNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_bl_img", property="companyBlImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_attorney_img", property="companyAttorneyImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
            @Result(column="cert_status", property="certStatus", jdbcType=JdbcType.TINYINT)
    })
    AccountDetail findByUserId(String userId);

    @Select({
            "select",
            "id, user_id, bank_num, tel, bank_code,wx_open_id, name, id_num, cert_type, front_img, contrary_img, ",
            "hand_img, create_time, company_name, company_cert_type, company_cert_num, company_bl_img, ",
            "company_attorney_img, type, cert_status",
            "from account_detail",
            "where id_num = #{idNum,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
            @Result(column="bank_num", property="bankNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
            @Result(column="bank_code", property="bankCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="wx_open_id", property="wxOpenId", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="id_num", property="idNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="cert_type", property="certType", jdbcType=JdbcType.TINYINT),
            @Result(column="front_img", property="frontImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="contrary_img", property="contraryImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="hand_img", property="handImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_cert_type", property="companyCertType", jdbcType=JdbcType.TINYINT),
            @Result(column="company_cert_num", property="companyCertNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_bl_img", property="companyBlImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_attorney_img", property="companyAttorneyImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
            @Result(column="cert_status", property="certStatus", jdbcType=JdbcType.TINYINT)
    })
    AccountDetail findByIdNumber(String idNum);


    @Select({
            "select",
            "id, user_id, bank_num, tel, bank_code,wx_open_id, name, id_num, cert_type, front_img, contrary_img, ",
            "hand_img, create_time, company_name, company_cert_type, company_cert_num, company_bl_img, ",
            "company_attorney_img, type, cert_status",
            "from account_detail",
            "where cert_status = 1 and type=#{type,jdbcType=VARCHAR}"
    })
    @Results({
            @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
            @Result(column="user_id", property="userId", jdbcType=JdbcType.VARCHAR),
            @Result(column="bank_num", property="bankNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="tel", property="tel", jdbcType=JdbcType.VARCHAR),
            @Result(column="bank_code", property="bankCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="wx_open_id", property="wxOpenId", jdbcType=JdbcType.VARCHAR),
            @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
            @Result(column="id_num", property="idNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="cert_type", property="certType", jdbcType=JdbcType.TINYINT),
            @Result(column="front_img", property="frontImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="contrary_img", property="contraryImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="hand_img", property="handImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
            @Result(column="company_name", property="companyName", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_cert_type", property="companyCertType", jdbcType=JdbcType.TINYINT),
            @Result(column="company_cert_num", property="companyCertNum", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_bl_img", property="companyBlImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="company_attorney_img", property="companyAttorneyImg", jdbcType=JdbcType.VARCHAR),
            @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
            @Result(column="cert_status", property="certStatus", jdbcType=JdbcType.TINYINT)
    })
    List<AccountDetail> findInReviewList(String type);


}